﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;


namespace SQLTask2
{
    public partial class AddRateForm : Form
    {
        private MySqlConnection pConn;
        private string[] queries = {//Fill main grid
                                    @"SELECT currencies.Currency_ID, currencies.Name 
                                     FROM currencies 
                                     ORDER BY currencies.Currency_ID"
                                   };

        public AddRateForm(MySqlConnection conn)
        {
            InitializeComponent();
            pConn = conn;
        }

        private void AddRateForm_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable ds2 = new DataTable();
                (new MySqlDataAdapter(queries[0], pConn)).Fill(ds2);
                comboBox1.DataSource = ds2;
                comboBox2.DataSource = ds2;
                comboBox1.DisplayMember = "Name";
                comboBox1.ValueMember = "Currency_ID";
                comboBox2.DisplayMember = "Name";
                comboBox2.ValueMember = "Currency_ID";
            }
            catch (MySqlException sqlExc)
            {
                MessageBox.Show(sqlExc.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}
